package top.infopub.mgr.sys.web;


import org.apache.commons.lang3.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import top.infopub.mgr.common.vo.RspVo;
import top.infopub.generic.GenericController;
import top.infopub.mgr.common.page.ParamPage;
import top.infopub.mgr.sys.service.VisitlogService;
import top.infopub.mgr.sys.vo.VisitLogVo;
import top.infopub.model.sys.Visitlog;

import com.github.pagehelper.Page;


/**
 * 管理后台访问日志管理
 * @author Awoke
 * @version 2018年10月15日
 * @see VisitLogController
 * @since
 */
@Controller
@RequestMapping("/visitLog")
public class VisitLogController extends GenericController {

    @Autowired
    private VisitlogService visitlogService;

    /**
     * 日志列表
     * @return
     */
    @RequestMapping("/list")
    public String list() {
        return "sys/layvisitLog-list";
    }
    
    /**
     * 根据条件获取获取列表数据
     * @return
     */
    @RequestMapping("/queryDataByCondition")
    public @ResponseBody RspVo<Visitlog> queryDataByCondition(VisitLogVo visitLogVo,
                                                                         ParamPage paramPage) {
        Page<Visitlog> page = new Page<Visitlog>();
        page.setPageNum(paramPage.getPage());
        page.setPageSize(paramPage.getLimit());
        if (visitLogVo.getEndDate() != null) {
            visitLogVo.setEndDate(DateUtils.addDays(visitLogVo.getEndDate(), 1));
        }
        page = visitlogService.selectDataByCondition(page, visitLogVo);
        return RspVo.getSuccessResponse(page.getTotal(), page.getResult());
    }

}
